package com.xucy.springboot.designmodel.creational.single;

/**
 * @Author xucy
 * @Date 2019-07-16 19:40
 * @Description jdk中 Runtime  Desktop  spring 中AbstractFactoryBean mybatis中ErrorContext
 **/

public class Test {
    public static void main(String[] args) {
        //双重锁懒汉式
        for(int i=0;i<2;i++){

            new Thread(new Runnable() {
                @Override
                public void run() {
                    Product product=Product.createProduct();
                    try {
                        Thread.sleep(30);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println(product);
                }
            }).start();

        }

        //静态内部类 懒汉式
        Product product=Product.newProduct();
        Product product1=Product.newProduct();
        System.out.println(product);
        System.out.println(product1);
    }
}
